


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Kolimi; Class: INTRO TO C PROGRAMMING; Subject: Computer Science; University: University of Alabama - Huntsville; Term: Spring 2011;
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Kolimi
Date: 22nd^ February 2011 Student Name:
Question 1: (20 points) a. What is a Programming Language? Give some examples of programming languages. b. What is an Operating system? Give some examples. c. What are various data types in C? Give the short forms you use in C. d. Define ALU and CPU. e. What is \n, why is it used in printf statement? For the next part of question1, Identify and correct the error(s) in if any, in each of the following statements: f. int number = 9; printf("The number is %d \n", &number); g. int number; scanf("%d", number); h. if( c < 7) printf(" c is less than 7 \n ); i. char vari; printf("Please enter either a or b \n"); scanf("%d", &vari); j. int a
Extra credit: k and j bits are extra credit. k. char choice; switch(choice) { case a: printf("you have chosen character 'a' in the menu"); break; default:printf("Sorry not a"); }
[Hint: Make use of if… else statements] [Please scroll down for the last question] Question 4: (20 points) Uses Switch case structure Write a program which prints the message: “Enter a character among c,p,t, or f where c - CBS p - PBS t - TBS f - FX” The program accepts a character input using scanf () and uses the switch…case structure. This is a part of a larger application which lets the user select TV channels. [Hint: Declare a character datatype variable for switch case and then scanf() value into this variable] When the user enters ‘c’ --- print “You have selected CBS – it’s on Channel 34” When the user enters ‘p’ --- print “You have selected PBS – it’s on Channel 29” When the user enters ‘t’ --- print “You have selected TBS – it’s on Channel 37” When the user enters ‘f’ --- print “You have selected FX – it’s on Channel 43” When the user enters something other than c, p, t, f – print “Currently not on the menu, try again later!”