Fundamental Programming Concepts

This forum is aimed at students with little or no programming experience. It aims to provide students with an understanding of the role computation can play in solving problems.
Forum rules
This forum aims to provide material related to computer programming languages, tools and designs.

Fundamental Programming Concepts

Unread postby UCERD.COM » Sat Mar 28, 2015 10:01 am

Basic Data Types : 
Code: Select all
char m_char;
string m_student_name;
int  m_cms;
double m_gpa;

Structure : 
Code: Select all
struct RIU
{
string m_student_name;
int  m_cms;
double m_gpa;
};
struct RIU m_class_2014 // single strcuture
struct RIU m_array_of_strucutre[max_student]; // array of strcutures

Data Entery in the arrays of structure using loop statments : 
Code: Select all
for(m_counter=0;m_counter<max_student;m_counter=m_counter+1)
{
cout<<"Value of the Counter "<<m_counter<<endl;
cout<<"Enter Name of the Student "<<endl;
cin>>m_class_2014[m_counter].m_student_name;
cout<<"Enter CMS of the Student "<<endl;
cin>>m_class_2014[m_counter].m_cms;
cout<<"Enter GPA of the Student "<<endl;
cin>>m_class_2014[m_counter].m_gpa;
m_counter=m_counter+1;
}


Search Data from the Array Strcutures : 
Code: Select all
string m_search;
cout<<"Enter Name of Student for Searching  "<<endl;
cin>>m_search;
for(m_counter=0;m_counter<max_student;m_counter=m_counter+1)
{
cout<<"Value of the Counter "<<m_counter<<endl;
if(m_search==m_class_2014[m_counter].m_student_name)
{
cout<<"Student Named "<<m_search <<" has CMS "<< m_class_2014[m_counter].m_cms << " and CGPA "<< m_class_2014[m_counter].m_gpa<<endl;
}
}


Function for a simple calculator : 
Code: Select all
int calculator(int input_1, int input_2, char m_operator)
{
int output;
switch(m_operator)
{
case '+':
output=input_1+input_2;
break;
case '-':
output=input_1-input_2;
break;
case '/':
output=input_1/input_2;
break;
case '*':
output=input_1*input_2;
break;
}
return output;
}

Image
Please Promote Our Work and website through yoursocial and professional network. We would highly appreciate your help.
Find us on FaceBook,Like and Share Please
User avatar
UCERD.COM
Site Admin
Site Admin
 
Posts: 958
Joined: Wed Jun 20, 2012 3:01 pm
Location: Barcelona
Has thanked: 13 times
Been thanked: 14 times
Blog: View Blog (1)

Return to Computer Sciences & Programming

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest

cron