C - Beginner level program Codes


Here are some beginner level program codes in the C language and its good for starters, who are stepping into the world of coding.

  • SUM OF TWO NUMBERS


#include<stdio.h>
#include<conio.h>
int main()
{
float a,b,sum;
printf("Enter the first number: ");
scanf("%f",&a);
printf("Enter the second number: ");
scanf("%f",&b);
sum = a + b;
printf("The Sum of the two numbers is %f",sum);
getch();
return(0);
}
view raw gistfile1.txt hosted with ❤ by GitHub


  • DISPLAYING NAME & AGE FROM USER
#include<stdio.h>
#include<conio.h>
int main()
{
char name[20];
int age;
printf("Enter your name: ");
scanf("%s",&name);
printf("Enter your age: ");
scanf("%d",&age);
printf("Hello %s and you are %d years old.",name,age);
getch();
return(0);
}
view raw gistfile1.txt hosted with ❤ by GitHub

  • DECIMAL, FLOATING POINT & CHARACTER INPUT

#include<stdio.h>
int main()
{
char a;
int b;
float c;
printf("Enter a Single Character: ");
scanf("%c",&a);
printf("Enter a Decimal Integer: ");
scanf("%d",&b);
printf("Enter a Floating point value: ");
scanf("%f",&c);
printf("The items you entered are %c , %d and %f",a,b,c);
getch();
return(0);
}
view raw gistfile1.txt hosted with ❤ by GitHub

  • ARITHMETIC OPERATIONS

#include<stdio.h>
#include<conio.h>
int main()
{
float a,b;
int c,d;
printf("Enter the first number: ");
scanf("%f",&a);
printf("Enter the second number: ");
scanf("%f",&b);
printf("\nThe sum of the two numbers is %f ",a+b);
printf("\nThe difference between the two numbers is %f ",a-b);
if(b==0)
{
printf("\nDivision is not possible.");
}
else
{
printf("\nThe quotient is %f",a/b);
c=(int)a;
d=(int)b;
printf("\nThe reminder of division is %d ",c%d);
}
getch();
return(0);
}
view raw gistfile1.txt hosted with ❤ by GitHub

Comments