User Tools

Site Tools


user:psechris:portfolio:cprogproject10

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

user:psechris:portfolio:cprogproject10 [2013/02/22 21:33] – created psechrisuser:psechris:portfolio:cprogproject10 [2013/03/05 04:31] (current) – [Code] psechris
Line 1: Line 1:
 +======Project: If Statements======
  
 +A project for CSCS 1320 by Paul Sechrist during the Spring 2013.
 +
 +=====Objectives=====
 +C program must:
 +  * Ask the user to enter a number
 +  * place entered value into a variable
 +  * display a message accordingly
 +       * if value < 50 "You suck"
 +       * if value == 50 "Way to ruin the joke."
 +       * if value > 50 "Well, someone's over compensating."
 +       
 +=====Code=====
 +<code c 1>
 +#include<stdio.h>
 +
 +int main()
 +{
 +        int a;
 +        fprintf(stdout, "Please enter a number:\n");
 +        fscanf(stdin,"%u", &a);
 +        if (a<50)
 +        {
 +                fprintf(stdout, "YOU SUCK! \n");
 +        }
 + 
 +        else if (a==50)
 +        {
 +                fprintf(stdout, "you ruined the joke....\n");
 +        }
 + 
 +        else if (a>50)
 +        {
 +                fprintf(stdout, "Wellllll, someone's over compensating");
 +        }
 +        return(0);
 +}
 +</code>
 +
 +=====Execution=====
 +<cli>
 +lab46:~/src$ ./numif
 +Please enter a number:
 +1
 +YOU SUCK! 
 +lab46:~/src$ ./numif
 +Please enter a number:
 +50
 +you ruined the joke....
 +lab46:~/src$ ./numif
 +Please enter a number:
 +100
 +Wellllll, someone's over compensating....
 +lab46:~/src$ 
 +</cli>
 +
 +=====Reflection=====
 +Fairly easy, good way to learn how to use if statements.
 +=====References=====
 +Kellen kinda helped.... a bit.