Anda di halaman 1dari 4

Assignment 1 Introduction to Computing and Programming

Ques. 1. Describe three benefits of the cloud computing model.


Ans: Cloud is a network of remote servers hosted on the Internet and used to
store, manage, and process data in place of local servers or personal
computers. The benefits of the cloud computing model are :
Work from anywhere
With cloud computing, if youve got an internet connection you can be at work.
And with most serious cloud services offering mobile apps, youre not restricted
by which device youve got to hand.
Security
Lost laptops are a billion dollar business problem. And potentially greater than
the loss of an expensive piece of kit is the loss of the sensitive data inside it.
Cloud computing gives you greater security when this happens. Because your
data is stored in the cloud, you can access it no matter what happens to your
machine. And you can even remotely wipe data from lost laptops so it doesnt
get into the wrong hands.
Flexibility
Cloud-based services are ideal for businesses with growing or fluctuating
bandwidth demands. If your needs increase its easy to scale up your cloud
capacity, drawing on the services remote servers. Likewise, if you need to scale
down again, the flexibility is baked into the service.
Q.2 ->Write a program that prints the numbers 1 to 4 on the same line.
Write the
program using the following methods.
a)Using one printf statement with no conversion specifiers.
b)Using one printf statement with four conversion specifiers.
c)Using four printf statements.
Solution:)
(a)
#include<stdio.h>
int main()
{
printf("1 2 3 4");
return 0;
}
(b)
#include<stdio.h>
int main()
{
printf("%d %d %d %d",1,2,3,4);
return 0;
}
(c)
#include<stdio.h>

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;
}

Q.5 -> Input an integer (5digits or fewer) containing only 0s


and 1s (i.e., a binaryinteger) and print its decimal
equivalent. [Hint:Use the remainder and division operators
to pick off the binary numbers digits one at a time from
right to left. Just as in the decimal number system, in which
the rightmost digit has a positional value of 1, and the next
digit left has a positional value of 10, then 100, then 1000,
and so on, in the binary number system the rightmost digit
has a positional value of 1, the next digit left has a
positional value of 2, then 4, then 8, and so on. Thus the
decimal number 234 can be interpreted as 4 * 1 + 3 * 10 + 2

* 100. The decimal equivalent of binary 1101 is 1 * 1 + 0 * 2


+1 * 4 + 1 * 8 or 1 + 0 + 4 + 8 or 13.]
Solution ->
#include<stdio.h>
#include<math.h>
int main()
{
int a,temp=0,temp1=0,i=0,dec=0,b=0;
printf("Enter Any Binary Integer : ");
scanf("%d",&a);
temp = a;
while(temp!=0)
{
temp1 = temp%10;
temp = temp/10;
b = pow(2,i);
dec = dec + b*temp1 ;
i++;
}
printf("\nThe Decimal Equivalent is : %d\n",dec);
return 0;}

Anda mungkin juga menyukai