Assignment 1 - Introduction To Computing and Progr
Assignment 1 - Introduction To Computing and Progr
int main()
{
printf("1\n");
printf("2\n");
printf("3\n");
printf("4\n");
return 0;
}
Q.3 ->Write a program that asks the user to enter two integers, obtain
the numbersfrom the user, then prints the larger number followed by
the words is larger.If the numbers are equal, print the message
These numbers are equal.Use only the single-selection form of the
if statement.
Solution:)
#include<stdio.h>
int main()
{
int a,b;
printf("Enter any two Numbers :");
scanf("%d %d",&a,&b);
if(a>b)
{
printf("%d is greater than %d",a,b);
}
if(b>a)
{
printf("%d is greater than %d",b,a);
}
if(a==b)
{
printf("Both the numbers are equal !!");
}
return 0;
}
Q.4->One large chemical company pays its salespeople on a
commission
basis. The sales people receive $200 per week plus 9% of their gross
sales
for
that
week.Introduction
to
Computers,
Structured
Programming and C Programming.
For example, a salesperson who sells $5000 worth of chemicals in a
week
receives $200 plus 9% of $5000, or a total of $650. Develop a program
that
will input each salespersons gross sales for last week and will
calculate and
display that salesperson's earnings.
Solution:)
#include<stdio.h>
int main()
{
float a,net=0;
printf("Enter the Sales in Dollars: or press -1 to exit \n");
scanf("%f",&a);
if(a!=-1)
{
while(a!=-1)
{
net = 200.0 + 0.09*a;
printf("\nThe net salary is : %f",net);
printf("enter the sales in dollars or press -1 to stop\n");
scanf("%f",&a);}}
else
{printf("process exited");
}
return 0;
}