Assignment Document

Programming for Engineers-1

Pages:

Preview:


  • "Programming forEngineers-11.It will not print but thefloat average, high_temp, low_temp;average will be 74.30003high_temp = 55.6;low_temp = 37.4;average = high_temp + low_temp/2.0;What is value of average?2.What is printed on the screen? x = 1inti =..

Preview Container:


  • "Programming forEngineers-11.It will not print but thefloat average, high_temp, low_temp;average will be 74.30003high_temp = 55.6;low_temp = 37.4;average = high_temp + low_temp/2.0;What is value of average?2.What is printed on the screen? x = 1inti = 0, x = 0;for(i = 1; i < 10; i++){if(i % 2 == 1)x = x+i;elsex--;break;}printf("\\nx = %d",x);3.What amount of memory is allocated for each of the following variable declarations:i) 5 bytesii) 4 bytesi)char str[15]= {„p?,„a?,„p?,„e?,?r?};iii) 20bytesii)float num = 8.0;iv) 4 bytesiii)int input[5];iv)char op = 65;4.What is printed on the screen? 0.000001/3 has to do with this#include <stdio.h>void main() {float r = 10, h = 10, PI = 3.14;float ans = (1/3)* PI * r * r * h; Programming for Engineers-1 Sessional-1Exam –(Spring 14)Page 2 / 7printf("%f", ans);}5. x != 9What will be printed on the screen?int main(){ int x = 2; if(x = 9) printf("x = 9\\n"); else printf("x != 9\\n");}4 will be printed6. What is printed on the screen:Sol:#include<stdio.h>Num=0+1int main()1>0{{num=1+1int num = 0; num=2num++;2>0if (num > 0)Num=2+1{Num=3num++;3>0if (num > 0)Num=3+1num++ ;Num=4elsenum--;}if (num > 0)num++;else if (num > 1)num--;elsenum--; printf("%d",num);}7.Look at the following fragment of a working code: 19, 59, 3, 59, 19 int a[5] = {19, 59, 3, 41, 15}; int i = 0, j = 0; for(j = 4; i < 5; i++, j--) {a[j] = a[i]; }Programming for Engineers-1 Sessional-1Exam –(Spring 14)Page 3 / 7 i = 0; for( ; i< 5 ; ) {printf("%d,", a[i]);i++; }What output will be printed on the screen?What will be printed on the screen? True8.int a=1, b=2, c=3; if(a==1 && b>2 || c>b) printf(“True”); elseprintf("False”);}9. What will be the output of the program, if user enters 3*****and 5 ? ***** *****int i,j,k,a,b;***** *****printf(“Enter two numbers:”); *****scanf(“%d %d”,&a, &b);**********for(i=0;i<a;i++)*****for(j=0;j<b;j++)*****{ ***** for(k=0;k<b;k++)*****printf(“*”);*****printf(“\\n”);***** }*****Programming for Engineers-1 Sessional-1Exam –(Spring 14)Page 4 / 710.Based on the implementation below what is the GPA of a If printf commandis given tostudent whose marks are 65? each if then program would if(nMarks > 90)give gpa asfGPA = 4.00;2.00 if(nMarks > 85)1.66fGPA = 3.66;1.33 if(nMarks > 80)1.00fGPA = 3.33; if(nMarks > 75) fGPA = 3.00; if(nMarks > 70)fGPA = 2.66; if(nMarks > 65) fGPA = 2.33; if(nMarks > 60) fGPA = 2.00; if(nMarks > 55)fGPA = 1.66; if(nMarks > 50) fGPA = 1.33; if(nMarks > 45)fGPA = 1.00; else fGPA = 0.0;11.Write a program to take two (2) integer values from the user. If the two numbers are exactlythe reverse of each other, then display “Hola numbers”, otherwise display “Non-Holanumbers”. For example, 451 and 154 are Hola numbers, 451 and 555 are not Hola numbers.(6 marks)Programming for Engineers-1 Sessional-1Exam –(Spring 14)Page 5 / 7#include<stdio.h>int main(){int a,b,c,d,e,f,g,h,c1,d1,e1,f1,g1,h1;scanf("%d %d",&a,&b);if (a==b){printf("not a hola number");}else{c=a/10;d=a%10;e=c/10;f=c%10;g=e/10;h=e%10;c1=b/10;d1=b%10;e1=c1/10;f1=c1%10;g1=e1/10;h1=e1%10;if (d==h1 && f==f1 && h==d1){printf("A hola number");}else {printf("non hola");}}12.Write a program that adds every third integer, beginning with2 (i.e., calculate the sum of2+5+8+11+...) for all values of that are less than 100. (4 marks)"

Why US?

Because we aim to spread high-quality education or digital products, thus our services are used worldwide.
Few Reasons to Build Trust with Students.

128+

Countries

24x7

Hours of Working

89.2 %

Customer Retention

9521+

Experts Team

7+

Years of Business

9,67,789 +

Solved Problems

Search Solved Classroom Assignments & Textbook Solutions

A huge collection of quality study resources. More than 18,98,789 solved problems, classroom assignments, textbooks solutions.

Scroll to Top