Sequential Program Examples
Sequential Program Examples
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 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);
}