Happy About the progress
This commit is contained in:
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
#include <cs50.h>
|
||||
|
||||
int main(void)
|
||||
|
||||
{
|
||||
char c = get_char("Do you agree? ");
|
||||
|
||||
if (c == 'y' || c == 'Y')
|
||||
|
||||
{
|
||||
printf("Agreed.\n");
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
printf("Not Agreed.'\n");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <cs50.h>
|
||||
#include <stdio.h>
|
||||
//Proacive Promise for future.
|
||||
void meow(int tiomes);
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int n = get_int("What's n? ");
|
||||
meow(n);
|
||||
}
|
||||
|
||||
void meow(int times)
|
||||
{
|
||||
for (int i = 0; i < times; i++)
|
||||
{
|
||||
printf("meow\n");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <cs50.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
|
||||
{
|
||||
int x = get_int("What's x? ");
|
||||
int y = get_int("what's y? ");
|
||||
|
||||
if (x < y)
|
||||
|
||||
{
|
||||
printf("x is greater than y\n");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <cs50.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
string answer = get_string("What's your name? ");
|
||||
printf("Hello, %s\n", answer);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
Conditional
|
||||
If (boolean-expression)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// If the boolean-expression evaluates to true , all lines of code between phrases.
|
||||
@@ -0,0 +1,39 @@
|
||||
#include <cs50.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
string name;
|
||||
int votes;
|
||||
|
||||
} candidate;
|
||||
|
||||
candidate get_candidate(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
candidate candidates[3];
|
||||
|
||||
for (int i =0; i <3; i++)
|
||||
{
|
||||
candidates[i] = get_candidate();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
printf("Candidate %i is named %s and has %i votes.\n",i + 1, candidates[i].name, candidates[i].votes);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Function to get a new candidate
|
||||
|
||||
candidate get_candidate(void)
|
||||
{
|
||||
candidate new_candidate;
|
||||
new_candidate.name = get_string("Name: ") ;
|
||||
new_candidate.votes = get_int("Votes:") ;
|
||||
|
||||
return new_candidate;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user