Professional Documents
Culture Documents
I Hereby Declare That This Assignment Is My Individual Work and I Have Not Copied It From Any Source. Shahwar Hasan
I Hereby Declare That This Assignment Is My Individual Work and I Have Not Copied It From Any Source. Shahwar Hasan
I Hereby Declare That This Assignment Is My Individual Work and I Have Not Copied It From Any Source. Shahwar Hasan
HOME WORK: #1
I hereby declare that this assignment is my individual work and I have not
copied it from any source.
SHAHWAR HASAN
PART A
Ans 1. Algorithm
Step 1. PRINT “Enter the numbers and 1 for +, 2 for -, 3 for *, 4 for /, 5 for %”.
Step 2. Input n1, n2 and choice.
Step 3. Is choice =1? If yes go to step 9, else go to step 4.
Step 4. Is choice =2? If yes go to step 10, else go to step 5.
Step 5. Is choice =3? If yes go to step 11, else go to step 6.
Step 6. Is choice =4? If yes go to step 12, else go to step 7.
Step 7. Is choice =5? If yes go to step 13, else go to step 8.
Step 8. PRINT “Wrong choice”. Go to 2.
Step 9. Compute ( n1+n2). Go to step 14.
Step 10. Compute ( n1-n2). Go to step 14.
Step 11. Compute (n1*n2). Go to step 14.
Step 12. Compute ( n1/n2). Go to step 14.
Step 13. Compute (n1%n2). Go to step 14.
Step 14. Print the output.
Step 15. Is continue? If yes goto step 2 else goto step 16.
Step 16. END.
Ans 2. FLOWCHART
START
Yes
Choice= Result=n1+n2
1 No Yes
Choice= Result=n1-n2
2 No
Yes
Choice= Result=n1*n2
3 No
Yes
Choice= Result=n1/n2
4 No
Yes
Choice= Result=n1%n2
No
5
No 0<Res<1000
Yes
Res<0Yes
Print “RESULT”
Print “O is only
probability”
STOP
Ans 3. Pseudo code
Start
Enter n1 and n2
Enter your choice
If(input=1)
R=n1+n2
Else If(input=2)
R=n1-n2
Else If(input=3)
R=n1*n2
Else If(input=4)
R=n1/n2
Else If(input=5)
R=n1%n2
End if
If(R>1000||R=0)
Print: Input data again
If(R<0)
Print: Zero is the only Possibility
If(R!=isdigit())
Print: Input Valid data
Else
Print :R
END.
Ans 5.
#include<stdio.h>
#include<conio.h>
#define PI 3.14 /*defining constant*/
void main()
{
float m,n,ar,ch; /*declaring variables*/
printf("Enter choice 1=cir,2=rec,3=sq,4=rect:"); /*display the message for choice*/
scanf("%f",&ch);
printf("Enter dimension keep n=0 for sq and cir\n"); /* Message for values*/
scanf("%f%f",&m,&n);
if(ch==1) /*condition for choice*/
{
#include<stdio.h>
#include<conio.h>
void main()
{
float user,loc;/*declaring variable for username*/
char pas; /*declaring variable for password*/
printf("Username-");
scanf("%f",&user);
printf("Location (1=head office, 2=branch, 3=corporate)-");
scanf("%f",&loc);
printf("Password:");
scanf("%s",&passward);
if(password=='#') /*condition for password*/
{
printf("GOOGLE WORLD ");
}
else
{
printf("WRONG ");
}
getch();
}