Skip to content

Instantly share code, notes, and snippets.

View ThePratikSah's full-sized avatar
🏠
Working from home

Pratik Sah ThePratikSah

🏠
Working from home
View GitHub Profile
//A simple code.
/*
Author: Pratik Sah
Topic: For printing Hello World!
*/
#include <stdio.h>
main() {
printf("Hello World!\n");
//here '\n' is used for printing a new line.
}
// Demo of a simple C program.
/*
Author: Pratik Sah
Date: 29-03-17
*/
#include <stdio.h>
main() {
printf("Hello World!\n");
//here \n is used for creating a new line.
//the execution starts from main()
/*
Author: Pratik Sah
Date: 30-03-17
*/
#include <stdio.h>
main() {
printf("*\n");
printf("**\n");
printf("***\n");
printf("****\n");
main() {
int num=10;
printf("%d", num); // Here %d is used for integer.
}
main() {
float num=10.232;
printf("%f", num); // Here %f is used for float.
}
main() {
char num='c';
printf("%c", num); // Here %c is used for character.
}
/*
Author: Pratik Sah
Topic: Addition of two numbers
*/
main() {
int a,b,c;
printf("Enter any two numbers:\n");
scanf("%d%d", &a, &b);
c=a+b;
printf("%d", c);
/*
Author: Pratik Sah
Topic: subtraction of two numbers
*/
main() {
int a,b,c;
printf("Enter any two numbers:\n");
scanf("%d%d", &a, &b);
c=a-b;
printf("%d", c);
/*
Author: Pratik Sah
Topic: To find the average of three numbers.
*/
main(){
float a,b,c,e;
printf("Enter 1st number:");
scanf("%f", &a);
printf("Enter 2nd number:");
scanf("%f", &b);
Auto | double | int | struct
break | else | long | switch
case | enum | register | typedef
char | extern | return | union
const | float | short | unsigned
continue | for | signed | void
default | goto | size of | volatile
do | if | static | while