Sequential Program Examples
Q. Write a program to find the sum of two input numbers.
 #include<stdio.h>
 void main()
 {
 int a,b,sum;
 printf("Enter the first number = ");
 scanf("%d",&a);
 printf("Enter the second number = ");
 scanf("%d",&b);
 sum=a+b;
 printf("\nSum of two number = %d",sum);
 }
Q. Write a program to find square of numbers.
 #include<stdio.h>
 void main()
 {
 int n,square;
 printf("Enter the number = ");
 scanf("%d",&n);
 square=n*n;
 printf("\nSquare of number = %d",square);
 }
Q. Write a program to find simple interest.
 #include<stdio.h>
 void main()
 {
 float p,t,r,si;
 printf("Enter Principal = ");
 scanf("%f",&p);
 printf("Enter time = ");
 scanf("%f",&t);
 printf("Enter Rate = ");
 scanf("%f",&r);
 si=(p*t*r)/100;
 printf("Simple Interest = %f",si);
 }
Q. Write a program to input two numbers and print remainder and quotient.
 #include<stdio.h>
 void main()
 {
 int a,b,c,d; //second number divides the first number;
 printf("Enter two numbers = ");
 scanf("%d%d",&a,&b);
 c=a/b;
 d=a%b;
 printf("Quotient = %d\nRemainder = %d",c,d);
 }
Q. Write a program to enter full name and print it on screen.
 #include<stdio.h>
 void main()
 {
 char name[50];
 printf("Enter your name = ");
 gets(name);
 printf("Your name is %s",name);
 }
Q. Write a program to input name, age and salary and print them on screen.
 #include<stdio.h>
 void main()
 {
 char name[50];
 int age;
 float salary;
 printf("Enter your name = ");
 gets(name);
 printf("Enter your age = ");
 scanf("%d",&age);
 printf("Enter your salary = ");
 scanf("%f",&salary);
 printf("\nName is %s",name);
 printf("\nAge = %d",age);
 printf("\nSalary = %.2f",salary);
 }
Q. Write a program to calculate area of circle.
 #include<stdio.h>
 void main()
 {
 float r,a;
 printf("Enter radius = ");
 scanf("%f",&r);
 a=3.14*r*r;
 printf("Area of Circle = %f",a);
 }
Q. Write a program to input, seconds and convert in into hour, minute and seconds
 #include<stdio.h>
 void main()
 {
 int s,h,r,d,m,a;
 printf("Enter Seconds = ");
 scanf("%d",&s);
 h=s/3600; //for hour
 r=s%3600;
 m=r/60; //for minute
 d=r%60;
 printf("Hour = %d\nMinute = %d\nSecond = %d",h,m,d);
 }