C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 27th, 2012, 08:08 AM
khaoula khaoula is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 khaoula User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 56 sec
Reputation Power: 0
Telecomunication program - pb with how to verifie that a nbr is included in an array-

I've been asked to write a program for which :

You are asked to write a C program for telecommunication company, the program 1- asks the user to enter his number.
2- displays which operator he is using.
3- asks him if: -he wants to buy credit ( in this case asks for the amount of money).
- he wants to talk to an agent ( and keeps talking until he presses 1 to hung out)
- he wants to send a default message for a friend who uses the same operator ( he should enter the number of the friend and the program verifies if it is the same operator, and displays a choice of four default messages [you are free to choose default messages] )

-he wants to exit.
The user should be able to make diffrent operations without closing the program, whenever an operation is finished , the programs goes back to the main menu.The program only exits when the user chooses “exit” from the menu.



my pbs were : 1-I don't know how to ( make the compiler verifie if it is the same operator )

2- while I am using the ( do while ) it keeps reapiting the " enter ur number " and when I switched it below it keeps reapiting only the 1st condition




this is my program if anyone could help me :


Code:
#include <stdio.h>
#include <stdlib.h>
int number,n,friendnumber,amountofmoney;
int operatorr;
 
int main()
{
do
    {
    printf("Enter your number please :\n");
    scanf("%d",&number);
    printf("You are now using the operator: 123\n");
 
    printf("press 2 to choose how to buy and 3 to talk to an agent and 1 to send a default msg and 0 if you want to exit ");
    scanf("%d",&n);
 
 
        if(n==2)
    {
 
          printf("\nyou will buy credit, enter your amount of money :");
          scanf("%d",&amountofmoney);
 
    }
    else if  (n==3)
    {
        printf("\nyou are now talking to an agent press 1 to hung out");
        scanf("%d",&n);
    }
    else if (n==1)
    {
        printf("\nif you want to send a default message to a friend enter his number : ");
        scanf("%d",&friendnumber);
        if (friendnumber[&number])
        {
            printf("Hi, how are you ?");
            printf("\nI need you in emergency");
            printf("\nlet's meet tonight");
            printf("\nI will be there ASAP");
        }
       else
       printf("\nyou're user is not using the same operator as you ");
    }
    }
    while (n!=0);
 
return 0;
}

Reply With Quote
  #2  
Old December 27th, 2012, 10:21 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,836 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 16 h 15 m 5 sec
Reputation Power: 1774
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
  #3  
Old December 27th, 2012, 11:15 AM
zedeneye1 zedeneye1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 52 zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level)zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level)zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 14 h 36 m 53 sec
Reputation Power: 1
here's something I did with some additions:


Code:
#include <stdio.h>
#include <stdlib.h>
int number,n,friendnumber,amountofmoney;
int operatorr,foperatorr;
long a,b,c,d,e,f;
int x;

char opa[]="operator 1";//number beginning with 100
char opb[]="operator 2";//number beginning with 200

int main()
{   printf("Enter your 7 digit number please :\n");
    scanf("%d",&number);
    a=(number/1000000);
    b=(number/100000)-(a*10);
    c=(number/10000)-(a*100)-(b*10);
    {{if(a==1)
    {
        if(b==0)
        {
            if(c==0)
                {operatorr=1;
                printf("you are using operator %d\n\n",operatorr);}
        }
    }}

    {
    if(a==2)

    {
        if(b==0)
        {
            if(c==0)
                {operatorr=2;
                printf("you are using operator %d\n\n",operatorr);}
        }
    }
    }}
{do
    {

    printf("press 2 to choose how to buy and 3 to talk to an agent and 1 to send a default msg and 0 if you want to exit ");
    scanf("%d",&n);


        if(n==2)
    {

          printf("\nyou will buy credit, enter your amount of money :");
          scanf("%d",&amountofmoney);

    }
    else if  (n==3)
    {
        printf("\nyou are now talking to an agent press 1 to hung out");
        scanf("%d",&n);
    }
    else if (n==1)
    {
        printf("\nif you want to send a default message to a friend enter his number : ");
        scanf("%d",&friendnumber);
        d=(friendnumber/1000000);
        e=(friendnumber/100000)-(d*10);
        f=(friendnumber/10000)-(d*100)-(e*10);
    {{if(d==1)
    {if(e==0)
    {if(f==0)
    foperatorr=1;}}}
    {if(d==2)
    {if(e==0)
    {if(f==0)
    foperatorr=2;}}}}

        {if(foperatorr==operatorr)
        {printf("you and you're friend are on the same operator.");
        printf("\nPlease choose from the following default messages.\n\n");
        printf("1. Hi, how are you ?");
        printf("\n2. I need you in emergency");
        printf("\n3. let's meet tonight");
        printf("\n4. I will be there ASAP");
        scanf("%d",&x);
        printf("\nmessage number %d sent to your friend.\n",x);}
        else
       printf("\nyou're friend is not using the same operator as you\n ");
    }}}
    while (n!=0);
    }
}

Reply With Quote
  #4  
Old December 27th, 2012, 11:24 AM
zedeneye1 zedeneye1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 52 zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level)zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level)zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 14 h 36 m 53 sec
Reputation Power: 1
Quote:
Originally Posted by salem


that is also un-answered...and probably posted by the same user ( just 4 hrs ago )

so.......?

Reply With Quote
  #5  
Old December 27th, 2012, 12:22 PM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,836 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 16 h 15 m 5 sec
Reputation Power: 1774
So....

Asking in more than one place

Asking the same question concurrently

> and probably posted by the same user ( just 4 hrs ago )
It's a FREE service, open 24 hours a day, 365 days a year.
Normal etiquette would be that posters would not abuse that by posting the same thing over and over.

Imagine if they'd got the same answer almost immediately - someone would have wasted their time answering the question.

If no one replies in a reasonable time frame (at least 24 hours), then finding another forum is permissible, providing that the questions are then cross-linked for reference by the original poster.

If you want answers in 4 hours, then pay someone who offers a quality of service guarantee.

Reply With Quote
  #6  
Old December 27th, 2012, 12:25 PM
zedeneye1 zedeneye1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 52 zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level)zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level)zedeneye1 User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 14 h 36 m 53 sec
Reputation Power: 1
Quote:
Originally Posted by salem
So....

Asking in more than one place

Asking the same question concurrently

> and probably posted by the same user ( just 4 hrs ago )
It's a FREE service, open 24 hours a day, 365 days a year.
Normal etiquette would be that posters would not abuse that by posting the same thing over and over.

Imagine if they'd got the same answer almost immediately - someone would have wasted their time answering the question.

If no one replies in a reasonable time frame (at least 24 hours), then finding another forum is permissible, providing that the questions are then cross-linked for reference by the original poster.

If you want answers in 4 hours, then pay someone who offers a quality of service guarantee.


ok i get it...valid point.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Telecomunication program - pb with how to verifie that a nbr is included in an array-

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap